Feeling

Feelings Table

Feelings at time of assessment

Feeling Strongly Disagree Disagree Neutral Agree Strongly Agree
Happy 53 (4) 127 (9) 386 (28) 557 (40) 267 (19)
Frustrated 267 (19) 564 (41) 299 (22) 201 (14) 59 (4)
Sad 286 (21) 634 (46) 292 (21) 129 (9) 49 (4)
Worried 257 (18) 512 (37) 282 (20) 266 (19) 73 (5)
Restless 268 (19) 519 (37) 327 (24) 234 (17) 42 (3)
Excited 68 (5) 325 (23) 532 (38) 296 (21) 169 (12)
Calm 53 (4) 171 (12) 444 (32) 504 (36) 218 (16)
Lonely 290 (21) 543 (39) 281 (20) 146 (11) 130 (9)
Bored 296 (21) 568 (41) 354 (25) 142 (10) 30 (2)
Sluggish 224 (16) 475 (34) 279 (20) 317 (23) 95 (7)

Feelings Charts

Location

Location Table

Location at time of assessment

Location No Yes
Bus, Train, or Vehicle 1308 (94) 82 (6)
Church 1363 (98) 27 (2)
Home 330 (24) 1060 (76)
Friend’s or Relative’s House 1295 (93) 95 (7)
Store / Mall 1365 (98) 25 (2)
Outdoors 1276 (92) 114 (8)
Other 1311 (94) 79 (6)
Restaurant 1386 (100) 4 (0)
School / Library 1390 (100) 0 (0)
Work 1368 (98) 22 (2)

Location Charts

Activity

Activity Table

Activity at time of assessment

Activity No Yes
Interacting With Someone 1035 (74) 355 (26)
Sitting 723 (52) 667 (48)
Sleeping 1097 (79) 293 (21)
Standing 1196 (86) 194 (14)
Talking 1127 (81) 263 (19)
Walking / Excercising 1281 (92) 109 (8)
Other 1146 (82) 244 (18)

Activity Charts

Physical Activity

Table Row

Physical activity yesterday (Yes / No)

Activity No Yes
Walked or Biked to Get Somewhere 780 (56) 610 (44)
Engaged in Physical Fitness 1163 (84) 227 (16)
Engaged in Physical Activity at Work or Home 710 (51) 680 (49)
Did None of These 1016 (73) 374 (27)
Used Pedometer 1330 (96) 60 (4)

Physical activity yesterday (Minutes)

Activity 10 Minutes or Less 11-20 Minutes 21-30 Minutes 31-40 Minutes 41-50 Minutes More than 50 Minutes
Walked or Biked to Get Somewhere 44 (7) 112 (18) 182 (30) 134 (22) 53 (9) 85 (14)
Engaged in Physical Fitness 12 (5) 20 (9) 47 (21) 57 (25) 44 (19) 47 (21)
Engaged in Physical Activity at Work or Home 24 (4) 60 (9) 129 (19) 181 (27) 114 (17) 172 (25)

Sitting time yesterday

Variable 4 or Fewer Hours More than 4 Hours- 6 Hours More than 6 Hours- 8 Hours More than 8 Hours- 10 Hours More than 10 Hours - 12 Hours More than 12 Hours
Sitting Time Yesterday 338 (24) 341 (25) 312 (22) 244 (18) 106 (8) 49 (4)

Physical Activity Charts

Diet

Table Row

Ate any yesterday (Yes / No)

Food No Yes
Fruit 435 (31) 955 (69)
Vegetables 272 (20) 1118 (80)
Sugar-Sweetened Beverages 462 (33) 928 (67)
Deserts and Other Sweets 608 (44) 782 (56)
Red Meat or Processed Meat 420 (30) 970 (70)

Servings ate yesterday

Food 0 Servings 1 Serving 2 Servings 3 Servings 4 Servings 5 or More Servings
Fruit 435 (31) 401 (29) 375 (27) 136 (10) 38 (3) 5 (0)
Vegetables 272 (20) 476 (34) 423 (30) 175 (13) 36 (3) 8 (1)
Sugar-Sweetened Beverages 462 (33) 311 (22) 216 (16) 182 (13) 72 (5) 147 (11)
Deserts and Other Sweets 608 (44) 459 (33) 195 (14) 96 (7) 24 (2) 8 (1)
Red Meat or Processed Meat 420 (30) 446 (32) 393 (28) 114 (8) 15 (1) 2 (0)

Diet Charts

Medication

Medication Table

Did you take all your medication as prescribed yesterday, and if not, which ones didn’t you take?

Medication No Yes
Take Medications 94 (7) 1296 (93)
Didn’t Take Depression / Anxiety / Mood Medication 1334 (96) 56 (4)
Didn’t Take Psychiatric Medication 1347 (97) 43 (3)
Didn’t Take Asthma / COPD Medication 1375 (99) 15 (1)
Didn’t Take Blood Pressure Medication 1353 (97) 37 (3)
Didn’t Take Diabetes Medication 1382 (99) 8 (1)
Didn’t Take Pain Medication 1373 (99) 17 (1)
Didn’t Take Cholesterol Medication 1385 (100) 5 (0)
Didn’t Take Antibiotic / Antiviral Medication 1388 (100) 2 (0)
Didn’t Take Other Medication 1365 (98) 25 (2)

Why didn’t you take medications?

Reason Wasn’t a Reason Was a Reason
Ran out 1331 (96) 59 (4)
Forgot 1363 (98) 27 (2)
Don’t Need It 1389 (100) 1 (0)
Side Effects 1389 (100) 1 (0)
Got Lost / Stolen 1390 (100) 0 (0)
Other 1372 (99) 18 (1)

Medication Charts

Freetime

Freetime Table

How much free time did you have yesterday?

Free time 2 or fewer hours More than 2 hours- 4 hours More than 4 hours- 6 hours More than 6 hours- 8 hours More than 8 hours- 10 hours More than 10 hours
Amount 183 (13) 254 (18) 279 (20) 263 (19) 208 (15) 203 (15)

What did you do in your free time yesterday?

Activity Didn’t Do Yesterday Did Yesterday
Watched TV 214 (15) 1176 (85)
Played Computer Games 1390 (100) 0 (0)
Went to a Movie 1390 (100) 0 (0)
Surfed the Internet 689 (50) 701 (50)
Read 1070 (77) 320 (23)
Listened to Music or Played Instrument 1049 (75) 341 (25)
Arts and Crafts 1232 (89) 158 (11)
Cleaned 782 (56) 608 (44)
Took Care of Pets 1125 (81) 265 (19)
Prayed, Meditated, or Went to Religious Service 997 (72) 393 (28)
Played a Sport 1365 (98) 25 (2)
Walk or Jog 1153 (83) 237 (17)
Played Cards, Dice, or Board Games 1390 (100) 0 (0)
Went Shopping 1170 (84) 220 (16)
Volunteered 1259 (91) 131 (9)
Socialized 899 (65) 491 (35)
None of These 1336 (96) 54 (4)

Freetime Charts

Interaction

Interaction Table

Any meaningful interaction yesterday

Type No Yes
One-On-One Conversations 215 (15) 1175 (85)
Group Interactions 675 (49) 715 (51)

Amount of meaningful interaction yesterday

Type 15 or Fewer Minutes 16-30 Minutes 31 min- 1 Hour More than 1 Hour- 2 Hours More than 2 Hours- 3 Hours More than 3 Hours- 4 Hours More than 4 Hours
One-On-One Conversations 215 (15) 185 (13) 283 (20) 293 (21) 213 (15) 95 (7) 106 (8)
Group Interactions 675 (49) 162 (12) 212 (15) 204 (15) 118 (8) 4 (0) 15 (1)

Interaction Charts

Substances

Substances Tables

Substances used yesterday

Type No Yes
Alcohol 1282 (92) 108 (8)
5 or More Alcoholic Drinks 94 (86) 15 (14)
Tobacco 791 (57) 599 (43)
Marijuana 1298 (93) 92 (7)
Opiates 1329 (96) 61 (4)
Stimulants 1383 (99) 7 (1)
Herbal Drugs / Incense 1389 (100) 1 (0)
Another drug 1390 (100) 0 (0)
None 748 (54) 642 (46)

Substances Charts

Session Info

#> R version 3.3.0 (2016-05-03)
#> Platform: x86_64-apple-darwin13.4.0 (64-bit)
#> Running under: OS X 10.11.5 (El Capitan)
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] dataclean_0.1.0     ggplot2_2.1.0       tidyr_0.4.1        
#> [4] knitr_1.13          dplyr_0.4.3         flexdashboard_0.2.0
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_0.12.4      magrittr_1.5     munsell_0.4.3    colorspace_1.2-6
#>  [5] R6_2.1.2         highr_0.5.1      stringr_1.0.0    plyr_1.8.3      
#>  [9] tools_3.3.0      parallel_3.3.0   grid_3.3.0       gtable_0.2.0    
#> [13] DBI_0.4-1        htmltools_0.3.5  lazyeval_0.1.10  yaml_2.1.13     
#> [17] assertthat_0.1   digest_0.6.9     formatR_1.3      evaluate_0.9    
#> [21] rmarkdown_0.9.6  labeling_0.3     stringi_1.0-1    scales_0.4.0    
#> [25] jsonlite_0.9.19
---
title: "Exploratory Analysis of Daily EMA Data"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
    source: embed
---

```{r setup, include=FALSE}
# Setup options
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")

# CRAN packages
library(flexdashboard)
library(dplyr)
library(knitr)
library(tidyr)
library(ggplot2)

# devtools::install_github("mbcann01/dataclean")
library(dataclean)

# Load ea_kable
source("/Users/bradcannell/Dropbox/Research/mChat/R scripts/ea_kable.R")

# Load data
load("/Users/bradcannell/Dropbox/Research/mChat/data/daily_april_2016.RData")

# Sort by case number and date
daily <- dplyr::arrange(daily, case_number, date)
```

Overview {.sidebar}
===============================================================================

Here we plot the aggregate unconditional distribution of responses for each of the following variables:

1. Feelings at time of assessment

2. Location at time of assessment

3. Activity at time of assessment

4. Physical activity yesterday

5. Diet yesterday

6. Medication use yesterday

7. Freetime activities yesterday

8. Meaningful Interaction yesterday

9. Substance use yesterday




Feeling
===============================================================================

Feelings Table
-------------------------------------------------------------------------------

### Feelings at time of assessment

```{r feeling_table}
feelings <- select(daily, happy, frustrated, sad, worried, restless, excited, calm, lonely, bored, sluggish)

vars <- tools::toTitleCase(names(feelings))

ea_kable(
  x = feelings, 
  xlab = vars, 
  nrows = 10, 
  ncols = 6, 
  colnames = c("Feeling", "Strongly Disagree", "Disagree", "Neutral", "Agree", 
    "Strongly Agree")
) 
```

Feelings Charts
-------------------------------------------------------------------------------

```{r plot_emotions}
for (var in vars) {
  plot <- ggplot(daily, aes_string(x = tolower(var))) +
    geom_bar() +
    scale_x_discrete("") +
    ggtitle(paste("I Feel", var, "Right Now")) +
    theme_bw()
  print(plot)
}
```









Location
===============================================================================

Location Table
-------------------------------------------------------------------------------

### Location at time of assessment

```{r location_table}
x <- select(daily, bus_loc, church_loc, home_loc, frifam_loc, store_loc, outdoors_loc, other_loc, restaurant_loc, school_loc, work_loc)

loc <- c("Bus, Train, or Vehicle", "Church", "Home", "Friend's or Relative's House", "Store / Mall", "Outdoors", "Other", "Restaurant", "School / Library", "Work")

ea_kable(
  x = x, 
  xlab = loc, 
  nrows = 10, 
  ncols = 3, 
  colnames = c("Location", "No", "Yes")
)
```

Location Charts
-------------------------------------------------------------------------------

```{r plot_location, fig.width=12}
# Summarize
x <- data.frame(sapply(x, table))

# Tidy data
x <- gather(x)

# Keep even numbered rows
x <- x[c(FALSE, TRUE), ]

# Improve readability
x$key <- loc

# Plot the data
ggplot(x, aes(x = key, y = value)) +
  geom_bar(stat = "identity") +
  scale_x_discrete("") +
  scale_y_continuous("Number of Responses") +
  ggtitle("Location at Time of Assessment") +
  theme_bw()
```









Activity
===============================================================================

Activity Table
-------------------------------------------------------------------------------

### Activity at time of assessment

```{r activity_table}
x <- select(daily, pre_who, sit_act, sleep_act, stand_act, talk_act, walk_act, other_act)

act <- c("Interacting With Someone", "Sitting", "Sleeping", "Standing", "Talking", "Walking / Excercising", "Other")

ea_kable(
  x = x, 
  xlab = act, 
  nrows = 7, 
  ncols = 3, 
  colnames = c("Activity", "No", "Yes")
)
```

Activity Charts
-------------------------------------------------------------------------------

```{r plot_act, fig.width=12}
x <- data.frame(sapply(x, table))
x <- gather(x)
x <- x[c(FALSE, TRUE), ]
x$key <- act

# Plot the data
ggplot(x, aes(x = key, y = value)) +
  geom_bar(stat = "identity") +
  scale_x_discrete("") +
  scale_y_continuous("Number of Responses") +
  ggtitle("Activity Immediately Prior to Assessment") +
  theme_bw()
```









Physical Activity
===============================================================================

Table Row {.tabset .tabset-fade}
-------------------------------------------------------------------------------

### Physical activity yesterday (Yes / No)

```{r physact_table_1}
x <- select(daily, bike_yest, run_yest, cleaning_yest, none_yest, pedometer)

act <- c("Walked or Biked to Get Somewhere", "Engaged in Physical Fitness", "Engaged in Physical Activity at Work or Home", "Did None of These", "Used Pedometer")

ea_kable(
  x = x, 
  xlab = act, 
  nrows = 5, 
  ncols = 3, 
  colnames = c("Activity", "No", "Yes")
)
```

### Physical activity yesterday (Minutes)

```{r physact_table_2}
x <- select(daily, min_walk, min_run, min_act)

act <- c("Walked or Biked to Get Somewhere", "Engaged in Physical Fitness", "Engaged in Physical Activity at Work or Home")

ea_kable(
  x = x, 
  xlab = act, 
  nrows = 3, 
  ncols = 7, 
  colnames = c("Activity", "10 Minutes or Less", "11-20 Minutes", "21-30 Minutes", 
    "31-40 Minutes", "41-50 Minutes", "More than 50 Minutes")
)
```

### Sitting time yesterday

```{r sitting_table}
x <- select(daily, min_sit)

ea_kable(
  x = x, 
  xlab = "Sitting Time Yesterday", 
  nrows = 1, 
  ncols = 7, 
  colnames = c("Variable", "4 or Fewer Hours", "More than 4 Hours- 6 Hours", 
    "More than 6 Hours- 8 Hours", "More than 8 Hours- 10 Hours", 
    "More than 10 Hours - 12 Hours", "More than 12 Hours")
)
```

Physical Activity Charts
-------------------------------------------------------------------------------

```{r plot_act_yest}
x <- names(select(daily, bike_yest, run_yest, cleaning_yest, none_yest, pedometer, min_walk, min_run, min_act, min_sit))
act <- c("Walked or Biked to Get Somewhere", "Engaged in Physical Fitness", "Engaged in Physical Activity at Work or Home", "Did None of These", "Used Pedometer", "Walked or Biked to Get Somewhere", "Engaged in Physical Fitness", "Engaged in Physical Activity at Work or Home", "Sat")
i <- 1
for (var in x) {
  plot <- ggplot(daily, aes_string(x = var)) +
    geom_bar() +
    scale_x_discrete("") +
    ggtitle(paste(act[i], "Yesterday")) +
    theme_bw() +
    if (i > 5) {
      theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
    } else {
      theme()
    }
  print(plot)
  i <- i + 1
}

# Plot steps
ggplot(daily, aes(x = steps)) +
  geom_histogram(binwidth = 1000) +
  scale_x_continuous("") +
  ggtitle("Steps Yesterday") +
  theme_bw()
```









Diet
===============================================================================

Table Row {.tabset .tabset-fade}
-------------------------------------------------------------------------------

### Ate any yesterday (Yes / No)

```{r diet_table_1}
x <- select(daily, any_fruit, any_veg, any_ssb, any_sweets, any_meat)

food <- c("Fruit", "Vegetables", "Sugar-Sweetened Beverages", "Deserts and Other Sweets", "Red Meat or Processed Meat")

ea_kable(
  x = x, 
  xlab = food, 
  nrows = 5, 
  ncols = 3, 
  colnames = c("Food", "No", "Yes")
)
```

### Servings ate yesterday

```{r diet_table_2}
x <- select(daily, serv_fruit, serv_veg, serv_ssb, serv_sweets, serv_meat)

food <- c("Fruit", "Vegetables", "Sugar-Sweetened Beverages", "Deserts and Other Sweets", "Red Meat or Processed Meat")

ea_kable(
  x = x, 
  xlab = food, 
  nrows = 5, 
  ncols = 7, 
  colnames = c("Food", "0 Servings", "1 Serving", "2 Servings", "3 Servings", "4 Servings", 
    "5 or More Servings")
)
```

Diet Charts
-------------------------------------------------------------------------------

```{r diet_yest}
x <- names(select(daily, any_fruit, any_veg, any_ssb, any_sweets, any_meat, serv_fruit, serv_veg, serv_ssb, serv_sweets, serv_meat))

food <- c("Fruit", "Vegetables", "Sugar-Sweetened Beverages", "Deserts and Other Sweets", "Red Meat or Processed Meat", "Fruit", "Vegetables", "Sugar-Sweetened Beverages", "Deserts and Other Sweets", "Red Meat or Processed Meat")

i <- 1
for (var in x) {
  plot <- ggplot(daily, aes_string(x = var)) +
    geom_bar() +
    scale_x_discrete("") +
    ggtitle(paste("Ate", food[i], "Yesterday")) +
    theme_bw()
  print(plot)
  i <- i + 1
}
```









Medication
===============================================================================

Medication Table {.tabset .tabset-fade}
-------------------------------------------------------------------------------

### Did you take all your medication as prescribed yesterday, and if not, which ones didn't you take?

```{r med_table_1}
x <- select(daily, take_meds, medtype_dep, medtype_psy, medtype_ast, medtype_bp, medtype_diab, medtype_pain, medtype_chol, medtype_anti, medtype_other)

xlab <- c("Take Medications", "Didn't Take Depression / Anxiety / Mood Medication", "Didn't Take Psychiatric Medication", "Didn't Take Asthma / COPD Medication", "Didn't Take Blood Pressure Medication", "Didn't Take Diabetes Medication", "Didn't Take Pain Medication", "Didn't Take Cholesterol Medication", "Didn't Take Antibiotic / Antiviral Medication", "Didn't Take Other Medication")

ea_kable(
  x = x, 
  xlab = xlab, 
  nrows = 10, 
  ncols = 3, 
  colnames = c("Medication", "No", "Yes")
)
```

### Why didn't you take medications?

```{r med_table_2}
x <- select(daily, meds_ran_out, meds_forgot, meds_no_need, meds_side, meds_lost, meds_other)

xlab <- c("Ran out", "Forgot", "Don't Need It", "Side Effects", "Got Lost / Stolen", "Other")

ea_kable(
  x = x, 
  xlab = xlab, 
  nrows = 6, 
  ncols = 3, 
  colnames = c("Reason", "Wasn't a Reason", "Was a Reason")
)
```

Medication Charts
-------------------------------------------------------------------------------
```{r med_chart, fig.width=12}
# Take Meds (Yes / No)
x <- select(daily, take_meds)
ggplot(x, aes(x = take_meds)) +
    geom_bar() +
    scale_x_discrete("") +
    ggtitle("Take All Medications as Prescribed Yesterday") +
    theme_bw()

# Which medications not taken
x <- select(daily, medtype_dep, medtype_psy, medtype_ast, medtype_bp, medtype_diab, medtype_pain, medtype_chol, medtype_anti, medtype_other)

xlab <- c("Depression / Anxiety / Mood", "Psychiatric", "Asthma / COPD", "Blood Pressure", "Diabetes", "Pain", "Cholesterol", "Antibiotic / Antiviral", "Other")

x <- data.frame(sapply(x, table))
x <- gather(x)
x <- x[c(FALSE, TRUE), ]
x$key <- xlab

ggplot(x, aes(x = key, y = value)) +
  geom_bar(stat = "identity") +
  scale_x_discrete("") +
  scale_y_continuous("Number of Responses") +
  ggtitle("Medication Not Taken Yesterday") +
  theme_bw()

# Why medication not taken
x <- select(daily, meds_ran_out, meds_forgot, meds_no_need, meds_side, meds_lost, meds_other)

xlab <- c("Ran out", "Forgot", "Don't Need It", "Side Effects", "Got Lost / Stolen", "Other")

x <- data.frame(sapply(x, table))
x <- gather(x)
x <- x[c(FALSE, TRUE), ]
x$key <- xlab

ggplot(x, aes(x = key, y = value)) +
  geom_bar(stat = "identity") +
  scale_x_discrete("") +
  scale_y_continuous("Number of Responses") +
  ggtitle("Reason Medication Not Taken Yesterday") +
  theme_bw()
```









Freetime
===============================================================================

Freetime Table {.tabset .tabset-fade}
-------------------------------------------------------------------------------

### How much free time did you have yesterday?

```{r freetime_table_1}
x <- select(daily, free_time)

xlab <- c("Amount")

ea_kable(
  x = x, 
  xlab = xlab, 
  nrows = 1, 
  ncols = 7, 
  colnames = c("Free time", "2 or fewer hours", "More than 2 hours- 4 hours", 
    "More than 4 hours- 6 hours", "More than 6 hours- 8 hours", "More than 8 hours- 10 hours", 
    "More than 10 hours")
)
```

### What did you do in your free time yesterday?

```{r freetime_table_2}
x <- select(daily, tv_free, games_free, movie_free, internet_free, book_free, music_free, craft_free, cleaned_free, pets_free, pray_free, sport_free, walk_free, cards_free, shop_free, volunteer_free, social_free, none_free)

xlab <- c("Watched TV", "Played Computer Games", "Went to a Movie", "Surfed the Internet", "Read", "Listened to Music or Played Instrument", "Arts and Crafts", "Cleaned", "Took Care of Pets", "Prayed, Meditated, or Went to Religious Service", "Played a Sport", "Walk or Jog", "Played Cards, Dice, or Board Games", "Went Shopping", "Volunteered", "Socialized", "None of These")

ea_kable(
  x = x, 
  xlab = xlab, 
  nrows = 17, 
  ncols = 3, 
  colnames = c("Activity", "Didn't Do Yesterday", "Did Yesterday")
)
```

Freetime Charts
-------------------------------------------------------------------------------
```{r freetime_chart, fig.width=12, fig.height=8}
# How much
x <- select(daily, free_time)

xlab <- c("Amount")

i <- 1
for (var in x) {
  plot <- ggplot(daily, aes_string(x = var)) +
    geom_bar() +
    scale_x_discrete("") +
    ggtitle("Amount of Free Time Yesterday") +
    theme_bw() +
    theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
  print(plot)
  i <- i + 1
}

# What they did during free time
x <- select(daily, tv_free, games_free, movie_free, internet_free, book_free, music_free, craft_free, cleaned_free, pets_free, pray_free, sport_free, walk_free, cards_free, shop_free, volunteer_free, social_free, none_free)

xlab <- c("Watched TV", "Played Computer Games", "Went to a Movie", "Surfed the Internet", "Read", "Listened to Music or Played Instrument", "Arts and Crafts", "Cleaned", "Took Care of Pets", "Prayed, Meditated, or Went to Religious Service", "Played a Sport", "Walk or Jog", "Played Cards, Dice, or Board Games", "Went Shopping", "Volunteered", "Socialized", "None of These")

x <- data.frame(sapply(x, table))
x <- gather(x)
x <- x[c(FALSE, TRUE), ]
x$key <- xlab

ggplot(x, aes(x = key, y = value)) +
  geom_bar(stat = "identity") +
  scale_x_discrete("") +
  scale_y_continuous("Number of Responses") +
  ggtitle("Free Time Activity Yesterday") +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
```









Interaction
===============================================================================

Interaction Table {.tabset .tabset-fade}
-------------------------------------------------------------------------------

### Any meaningful interaction yesterday

```{r interaction_table_1}
x <- select(daily, any_talk, any_group)

xlab <- c("One-On-One Conversations", "Group Interactions")

ea_kable(
  x = x, 
  xlab = xlab, 
  nrows = 2, 
  ncols = 3, 
  colnames = c("Type", "No", "Yes")
)
```

### Amount of meaningful interaction yesterday

```{r interaction_table_2}
x <- select(daily, min_talk, min_group)

xlab <- c("One-On-One Conversations", "Group Interactions")

ea_kable(
  x = x, 
  xlab = xlab, 
  nrows = 2, 
  ncols = 8, 
  colnames = c("Type", "15 or Fewer Minutes", "16-30 Minutes", "31 min- 1 Hour", 
    "More than 1 Hour- 2 Hours", "More than 2 Hours- 3 Hours", "More than 3 Hours- 4 Hours", 
    "More than 4 Hours")
)
```

Interaction Charts
-------------------------------------------------------------------------------
```{r interaction_chart}
# Any interaction
x <- select(daily, any_talk, any_group)

xlab <- c("One-On-One Conversations", "Group Interactions")

i <- 1
for (var in x) {
  plot <- ggplot(daily, aes_string(x = var)) +
    geom_bar() +
    scale_x_discrete("") +
    ggtitle(paste(xlab[i], "Yesterday")) +
    theme_bw()
  print(plot)
  i <- i + 1
}
  
# Amount of interaction
x <- select(daily, min_talk, min_group)

xlab <- c("One-On-One Conversations", "Group Interactions")

i <- 1
for (var in x) {
  plot <- ggplot(daily, aes_string(x = var)) +
    geom_bar() +
    scale_x_discrete("") +
    ggtitle(paste("Amount of", xlab[i], "Yesterday")) +
    theme_bw() +
    theme(axis.text.x = element_text(angle = 45, vjust = 0.5))
  print(plot)
  i <- i + 1
}
```









Substances
===============================================================================

Substances Tables
-------------------------------------------------------------------------------

### Substances used yesterday

```{r substance_table}
x <- select(daily, alc_sub, heavy_drink, cig_sub, mar_sub, opi_sub, stim_sub, herb_sub, other_sub, none_sub)

xlab <- c("Alcohol", "5 or More Alcoholic Drinks", "Tobacco", "Marijuana", "Opiates", "Stimulants", "Herbal Drugs / Incense", "Another drug", "None")

ea_kable(
  x = x, 
  xlab = xlab, 
  nrows = 9, 
  ncols = 3, 
  colnames = c("Type", "No", "Yes")
)
```

Substances Charts
-------------------------------------------------------------------------------

```{r substance_chart}
x <- names(select(daily, alc_sub, cig_sub, mar_sub, opi_sub, stim_sub, herb_sub, other_sub, none_sub))
sub <- c("Alcohol", "Tobacco", "Marijuana", "Opiates", "Stimulants", "Herbal Drugs", "Another drug", "No Substances")
i <- 1
for (var in x) {
  plot <- ggplot(daily, aes_string(x = var)) +
    geom_bar() +
    scale_x_discrete("") +
    ggtitle(paste("Participant used", sub[i], "Yesterday")) +
    theme_bw()
  print(plot)
  i <- i + 1
}
```




Session Info
===============================================================================
```{r session_info, echo=FALSE}
sessionInfo()
```